package com.example.mealplanner;

import java.util.ArrayList;
import java.util.List;

import com.example.mealplanner.login.LoginActivity;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class ProfileActivity extends Activity {
	
	private ListView profileList;
	private List<String> options;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_profile);
		
		profileList = (ListView) findViewById(R.id.profileList);
		
		options = new ArrayList<String>();
		options.add("Homepage");
		options.add("My points");
		options.add("Comments");
		options.add("Help");
		options.add("Logout");
		
	    final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
	            android.R.layout.simple_list_item_1, options);
	    profileList.setAdapter(adapter);
	    profileList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view0, int position,
					long id) {
				// TODO Auto-generated method stub
				final String item = (String) parent.getItemAtPosition(position);
				if(item.equals("Logout")){
					userLogout();
				}
				else 
					Toast.makeText(getApplicationContext(), item, Toast.LENGTH_SHORT).show();
			}
		});
	    
	}

	protected void userLogout() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(this, LoginActivity.class);
		startActivity(intent);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.profile, menu);
		return true;
	}
	
}
